Comparison between the ages for the sexes and microbiotes
Table of content
Generated from a Jupyter Notebook - Sources
source("load_libraries.R")
source("functions.R")
load("../results/dge/gene_length.RData")
load("../results/dge/filtered_metadata.RData")
load("../results/dge/dge.RData")
load("../results/dge/contrasts.RData")
load("../results/dge/filtered_norm_counts.RData")
load("../results/dge/filtered_z_scores.RData")
load("../results/dge/dge_net_pal2.RData")
load("../results/dge/col_order.RData")
load("../results/dge/annot_col.RData")
load("../results/dge/genes_in_modules.RData")
dir_path = "age-effect/age-microbiote-sex/"
Extract DEG between Middle-aged and Young, Old and Young and Old and Middle-aged for the different sex and microbiote combinations
Table with the factors
sub_contrasts = contrasts %>%
filter(Info == 'Middle-aged vs Young (Female, SPF)' |
Info == 'Middle-aged vs Young (Female, GF)' |
Info == 'Middle-aged vs Young (Male, SPF)' |
Info == 'Middle-aged vs Young (Male, GF)' |
Info == 'Old vs Young (Female, SPF)' |
Info == 'Old vs Young (Female, GF)' |
Info == 'Old vs Young (Male, SPF)' |
Info == 'Old vs Young (Male, GF)' |
Info == 'Old vs Middle-aged (Female, SPF)' |
Info == 'Old vs Middle-aged (Female, GF)' |
Info == 'Old vs Middle-aged (Male, SPF)' |
Info == 'Old vs Middle-aged (Male, GF)')
sub_contrasts
deg_results = lapply(sub_contrasts$Info, function(x) get_dge_results(x, dge, sub_contrasts))
names(deg_results) = sub_contrasts$Info
Extract the log2FC of the DEG
deg = extract_DEG_log2FC(deg_results, dir_path)
deg = extract_DEG_stats(deg, dir_path)
deg$stat
All DEG (Wald padj < 0.05)
plot_sign_DEG_upset(deg)
DEG (Wald padj < 0.05 & abs(FC) > 1.5)
pdf(paste('../results/dge/', dir_path, '/sign_FC_DEG_upset.pdf', sep=''))
plot_sign_FC_DEG_upset(deg)
dev.off()
plot_sign_FC_DEG_upset(deg)
data = deg$sign_fc_deg %>% select(-genes)
fc_annot = data.frame(Comparison = c(rep("Middle-aged VS Young",4), rep("Old VS Young",4), rep("Old VS Middle-aged",4)),
Sex = rep(c(rep("Female",2),rep("Male",2)),3),
Microbiote = rep(c("SPF","GF"),6),
row.names = colnames(data))
fc_annot
plot_fc_heatmap(data, fc_annot)
comps = list(
"Middle-aged vs Young (Female, SPF)" = c(grep("SPF_8w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_52w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"Old vs Middle-aged (Female, SPF)" = c(grep("SPF_52w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_104w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"Old vs Young (Female, SPF)" = c(grep("SPF_8w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_104w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"Middle-aged vs Young (Male, SPF)" = c(grep("SPF_8w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_52w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"Old vs Middle-aged (Male, SPF)" = c(grep("SPF_52w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_104w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"Old vs Young (Male, SPF)" = c(grep("SPF_8w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_104w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"Middle-aged vs Young (Female, GF)" = c(grep("GF_8w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_52w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"Old vs Middle-aged (Female, GF)" = c(grep("GF_52w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_104w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"Old vs Young (Female, GF)" = c(grep("GF_8w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_104w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"Middle-aged vs Young (Male, GF)" = c(grep("GF_8w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_52w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"Old vs Middle-aged (Male, GF)" = c(grep("GF_52w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_104w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"Old vs Young (Male, GF)" = c(grep("GF_8w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_104w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE))
)
plot_z_score_heatmap(z_scores,
deg$sign_fc_deg$genes,
col_order$msa,
annot_col$msa,
"All DE genes in age comparison for any sex and microbiote",
col_order$msa)
for(comp in names(comps)){
plot_z_score_heatmap(z_scores,
deg$sign_fc_deg %>% filter(!is.na((!!as.name(comp)))) %>% pull(genes),
col_order$msa,
annot_col$msa,
paste("DE genes in", comp),
comps[[comp]])
}
plot_z_score_heatmap(z_scores,
deg$sign_fc_deg$genes,
col_order$sma,
annot_col$sma,
"All DE genes in age comparison for any sex and microbiote",
col_order$sma)
pdf(paste('../results/dge/', dir_path, '/z_score_gta.pdf', sep=''))
plot_z_score_heatmap(z_scores,
deg$sign_fc_deg$genes,
col_order$sma,
annot_col$sma,
"All DE genes in age comparison for any sex and microbiote",
col_order$sma)
dev.off()
for(comp in names(comps)){
plot_z_score_heatmap(z_scores,
deg$sign_fc_deg %>% filter(!is.na((!!as.name(comp)))) %>% pull(genes),
col_order$sma,
annot_col$sma,
paste("DE genes in", comp),
comps[[comp]])
}
comps = names(comps)
plot_z_score_heatmap_with_modules(z_scores,
rownames(z_scores),
col_order$msa,
annot_col$msa,
genes_in_modules,
"All genes")
for(comp in comps){
plot_z_score_heatmap_with_modules(z_scores,
deg$sign_fc_deg %>% filter(!is.na((!!as.name(comp)))) %>% pull(genes),
col_order$msa,
annot_col$msa,
genes_in_modules,
paste("DE genes in", comp))
}
plot_z_score_heatmap_with_modules(z_scores,
rownames(z_scores),
col_order$sma,
annot_col$sma,
genes_in_modules,
"All genes")
for(comp in comps){
plot_z_score_heatmap_with_modules(z_scores,
deg$sign_fc_deg %>% filter(!is.na((!!as.name(comp)))) %>% pull(genes),
col_order$sma,
annot_col$sma,
genes_in_modules,
paste("DE genes in", comp))
}
for(comp in comps){
plot_top_deg_in_modules(deg$sign_fc_deg, comp, genes_in_modules)
}
options(repr.plot.width=7, repr.plot.height=7)
deg = fit_proba_weighting_function(deg, gene_length)
deg = extract_GO_terms(deg, dir_path)
Dot-plot with the 10 most significant p-values for the different comparison
plot_top_go(deg, "BP", 10)
Dot-plot with the most over-represented CC GO (20 most significant p-values for the different comparison)
plot_top_go(deg, "CC", 10)
Dot-plot with the most over-represented MF GO (20 most significant p-values for the different comparison)
plot_top_go(deg, "MF", 10)
The edge colors in the tree represent the relationship between two nodes. - green: positively regulates
GO Trees at "../results/dge/age-effect/age-microbiote-sex/go"
for(comp in comps){
print(comp)
fn = gsub(' ', '_', comp)
fn = gsub('(\\(|\\)|,)', '', fn)
fp = paste('../results/dge/', dir_path, 'go/', fn, '.png', sep='')
col = get_GO_network_col_all_ont(deg$GO, comp)
dotRes = getAmigoTree(goIDs=col$category,
color=col$color,
filename=fp,
picType="png",
saveResult=TRUE)
}
deg = extract_KEGG_pathways(deg, dir_path)
plot_kegg_pathways(deg$KEGG$over$category,
deg$sign_fc_deg,
paste('../results/dge/', dir_path, '/kegg/over_repr_kegg/', sep=''))
Pathway graphs available at ../results/dge/age-effect/age_type_gender/over_repr_kegg/
plot_kegg_pathways(deg$under_represented_KEGG[,"category"],
deg$fc_deg,
paste('../results/dge/', dir_path, '/kegg/under_repr_kegg/', sep=''))
Pathway graphs available at ../results/dge/age-effect/age_type_gender/under_repr_kegg/